import request from './request';

const api_vue = process.env.VUE_APP_API;

// 轮播图
export const bannerList = num => {
  return request({
    method: 'get',
    url: `${api_vue}/banner?type=${num}&timestamp=${new Date().getTime()}`
  });
}
// 个性推荐列表
export const personalized = () => {
  return request({
    method: 'get',
    url: `${api_vue}/personalized?limit=20&timestamp=${new Date().getTime()}`
  })
}
// 歌单顶部展示
export const tophighquality = (tag = '华语', num = 1) => {
  return request({
    method: 'get',
    url: `${api_vue}/top/playlist/highquality?limit=${num}&cat=${tag}`
  })
}
// 歌单列表
export const playList = (cat = '华语', order = 'hot', offset = '0') => {
  return request({
    method: 'get',
    url: `${api_vue}/top/playlist?limit=50&order=${order}&cat=${cat}&offset=${offset}`
  })
}
// 热门歌单分类
export const hotPlayTag = () => {
  return request({
    method: 'get',
    url: `${api_vue}/playlist/hot?timestamp=${new Date().getTime()}`
  })
}
// 歌单分类
export const catList = () => {
  return request({
    method: 'get',
    url: `${api_vue}/playlist/catlist?timestamp=${new Date().getTime()}`
  })
}
// 所有榜单
export const topList = () => {
  return request({
    method: 'get',
    url: `${api_vue}/toplist?timestamp=${new Date().getTime()}`
  })
}
// 获取歌单详情, 后续移入到detail中
export const playDetail = id => {
  return request({
    method: 'get',
    url: `${api_vue}/playlist/detail?id=${id}&timestamp=${new Date().getTime()}`
  })
}

// 获取更多歌单详情
export const morePlayDetail = ids => {
  return request({
    method: 'get',
    url: `${api_vue}/song/detail?ids=${ids}&timestamp=${new Date().getTime()}`,
  })
}

/**
 * 
 * @param {*} type -1:全部 1:男歌手 2:女歌手 3:乐队
 * @param {*} area -1:全部 7华语 96欧美 8:日本 16韩国 0:其他
 * @param {*} initial 按首字母索引查找参数,热门传-1,#传 0
 * @param {*} offset 偏移量,用于分页
 * @param {*} limit 返回数量
 * @returns 
 */
export const artistList = params => {
  return request({
    method: 'get',
    url: `${api_vue}/artist/list`,
    params
  })
}

/**
 * @param {*} type 全部:0 华语:7 欧美:96 日本:8 韩国:16
 * @returns 
 */
export const zuixinMusic = type => {
  return request({
    method: 'get',
    url: `${api_vue}/top/song?type=${type}&timestamp=${new Date().getTime()}`
  })
}

// 新碟上架
export const topAlbum = params => {
  return request({
    method: 'get',
    url: `${api_vue}/top/album`,
    params
  })
}

// 收藏或取消收藏歌手
export const subArtist = params => {
  return request({
    method: 'get',
    url: `${api_vue}/artist/sub`,
    params
  })
}

// 收藏或取消收藏专辑
export const subAlbum = params => {
  return request({
    method: 'get',
    url: '/album/sub',
    params
  })
}

// 收藏或取消收藏视频
export const subVideo = params => {
  return request({
    method: 'get',
    url: `${api_vue}/video/sub`,
    params
  })
}

// 收藏或取消收藏MV
export const subMV = params => {
  return request({
    method: 'get',
    url: `${api_vue}/mv/sub`,
    params
  })
}

// 点赞/取消点赞评论
export const commentLike = params => {
  return request({
    method: 'get',
    url: `${api_vue}/comment/like`,
    params
  })
}

// 点赞/取消点赞mv、视频
export const likeResource = params => {
  return request({
    method: 'get',
    url: `${api_vue}resource/like`,
    params
  })
}

// 关注/取消关注用户
export const followUser = params => {
  return request({
    method: 'get',
    url: `${api_vue}/follow`,
    params
  })
}

// 收藏或取消收藏歌单
export const subList = params => {
  return request({
    method: 'get',
    url: `${api_vue}/playlist/subscribe`,
    params
  })
}